home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Assembly Language Step by Step
/
Assembly Language Step by Step.mdf
/
ForDOS
/
ASM
/
VIDLIB.ASM
< prev
next >
Wrap
Assembly Source File
|
1999-09-12
|
6KB
|
161 lines
; Source name : VIDLIB.ASM
; Compiled name : VIDLIB.OBJ
; Code model: : Real mode segmented model
; Version : 1.0
; Created date : 9/12/1999
; Last update : 9/12/1999
; Author : Jeff Duntemann
; Description : A simple example of a separately assembled module
; containing utility procedures for controlling the
; PC display. Assembled using NASM 0.98. DOS programs
; can link to these routines by declaring them EXTERN
; and then linking the program .OBJ to VIDLIB.OBJ using
; a linker like ALINK.
[BITS 16] ; Set 16 bit code generation
;----------------------------|
; BEGIN DATA SEGMENT |
;----------------------------|
SEGMENT data PUBLIC
;Note that the following items are defined externally to this module, and
; for certain routines in this module to function these data items must
; be linked in from a properly assembled external module.
EXTERN CRLF,LRXY
;----------------------------|
; BEGIN CODE SEGMENT |
;----------------------------|
SEGMENT code PUBLIC ; This segment may be accessed externally
; Note that the following items are GLOBAL, and may be accessed by
; external files that declare them EXTERN.
GLOBAL GotoXY,ClrScr,ClrWin,ScrlWin,VIDEO6
GLOBAL Write,Writeln
;---------------------------------------------------------------
; GOTOXY -- Positions the hardware cursor to X,Y
; Last update 9/12/99
;
; 1 entry point:
;
; GotoXY:
; Caller must pass:
; DL: X value These are both 0-based; i.e., they
; DH: Y value assume a screen 24 by 79, not 25 by 80
; Action: Moves the hardware cursor to the X,Y position
; loaded into DL and H.
;---------------------------------------------------------------
GotoXY:
mov AH,02H ; Select VIDEO service 2: Position cursor
mov BH,0 ; Stay with display page 0
int 10H ; Call VIDEO
ret ; Return to the caller
;---------------------------------------------------------------
; CLRSCR -- Clears or scrolls screens or windows
; Last update 9/12/99
;
; 4 entry points:
;
; ClrScr:
; No values expected from caller
; Action: Clears the entire screen to blanks with 07H as
; the display attribute
;
; ClrWin:
; Caller must pass:
; CH: Y coordinate, upper left corner of window
; CL: X coordinate, upper left corner of window
; DH: Y coordinate, lower right corner of window
; DL: X coordinate, lower right corner of window
; Action: Clears the window specified by the caller to
; blanks with 07H as the display attribute
;
; ScrlWin:
; Caller must pass:
; CH: Y coordinate, upper left corner of window
; CL: X coordinate, upper left corner of window
; DH: Y coordinate, lower right corner of window
; DL: X coordinate, lower right corner of window
; AL: number of lines to scroll window by (0 clears it)
; Action: Scrolls the window specified by the caller by
; the number of lines passed in AL. The blank
; lines inserted at screen bottom are cleared
; to blanks with 07H as the display attribute
;
; VIDEO6:
; Caller must pass:
; CH: Y coordinate, upper left corner of window
; CL: X coordinate, upper left corner of window
; DH: Y coordinate, lower right corner of window
; DL: X coordinate, lower right corner of window
; AL: number of lines to scroll window by (0 clears it)
; BH: display attribute for blanked lines (07H is "normal")
; Action: Generic access to BIOS VIDEO service 6. Caller
; must pass ALL register parameters as shown above
;---------------------------------------------------------------
ClrScr:
mov CX,0 ; Upper left corner of full screen
mov DX,word [LRXY] ; Load lower-right XY coordinates into DX
ClrWin: mov AL,0 ; 0 specifies clear entire region
ScrlWin: mov BH,07H ; Specify "normal" attribute for blanked line(s)
VIDEO6: mov AH,06H ; Select VIDEO service 6: Initialize/Scroll
int 10H ; Call VIDEO
ret ; Return to the caller
;---------------------------------------------------------------
; WRITE -- Displays information to the screen via DOS
; service 9: Print String
; Last update 9/12/99
;
; 1 entry point:
;
; Write:
; Caller must pass:
; DS: The segment of the string to be displayed
; DX: The offset of the string to be displayed
; String must be terminated by "$"
; Action: Displays the string at DS:DX up to the "$" marker
;---------------------------------------------------------------
Write:
mov AH,09H ; Select DOS service 9: Print String
int 21H ; Call DOS
ret ; Return to the caller
;---------------------------------------------------------------
; WRITELN -- Displays information to the screen via DOS
; service 9 and issues a newline
; Last update 9/12/99
;
; 1 entry point:
;
; Writeln:
; Caller must pass:
; DS: The segment of the string to be displayed
; DX: The offset of the string to be displayed
; String must be terminated by "$"
; Action: Displays the string at DS:DX up to the "$" marker
; marker, then issues a newline. Hardware cursor
; will move to the left margin of the following
; line. If the display is to the bottom screen
; line, the screen will scroll.
; Calls: Write
;---------------------------------------------------------------
Writeln:
call Write ; Display the string proper through Write
mov DX,CRLF ; Load address of newline string to DS:DX
call Write ; Display the newline string through Write
ret ; Return to the caller